package com.house.api.controller;

import com.house.common.result.Result;
import com.house.model.dto.EvaluateDto;
import com.house.model.dto.ExpediteDto;
import com.house.model.dto.SubscribeLookHouseDto;
import com.house.model.entity.SubscribeLookHouse;
import com.house.model.vo.SubscribeLookHouseVo;
import com.house.service.service.ISubscribeLookHouseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/subscribe")
@Api(tags = "预约看房相关接口",value = "预约看房相关接口")
public class SubscribeLookHouseController {

    @Autowired
    private ISubscribeLookHouseService subscribeLookHouseService;

        @PostMapping("/add")
    @ApiOperation(value = "创建预约")
    public Result create(@RequestBody SubscribeLookHouse subscribeLookHouse) {
        subscribeLookHouseService.create(subscribeLookHouse);
        return Result.ok();
    }

    @PutMapping("/expedite")
    @ApiOperation(value = "催单")
    public Result expedite(@RequestBody ExpediteDto dto) {
        subscribeLookHouseService.changeExpedite(dto);
        return Result.ok();
    }

    @PutMapping()
    @ApiOperation(value = "修改状态")
    public Result changeStates(@RequestBody SubscribeLookHouseDto dto) {
        subscribeLookHouseService.changeStates(dto);
        return Result.ok();
    }

    @GetMapping("/getMy")
    @ApiOperation(value = "查询我的预约列表")
    public Result getMyList() {
        List<SubscribeLookHouseVo> mySubscribeLookHouseList = subscribeLookHouseService.getMySubscribeLookHouseList();
        return Result.ok(mySubscribeLookHouseList);
    }

    @GetMapping("/getTo")
    @ApiOperation(value = "查询我收到的预约列表")
    public Result getToList() {
        List<SubscribeLookHouseVo> toSubscribeLookHouseList = subscribeLookHouseService.getToSubscribeLookHouseList();
        return Result.ok(toSubscribeLookHouseList);
    }

    @GetMapping("/getMyCount")
    @ApiOperation(value = "查询我的预约数量")
    public Result getMyListCount() {
        Long myListCount = subscribeLookHouseService.getMyListCount();
        return Result.ok(myListCount);
    }

    @PutMapping("/evaluate")
    @ApiOperation(value = "评价")
    public Result evaluate(@RequestBody EvaluateDto dto) {
        subscribeLookHouseService.evaluate(dto);
        return Result.ok();
    }

    @GetMapping("/hotspot")
    @ApiOperation(value = "查询是否有催单预约")
    public Result hotspot(){
        boolean hotspot = subscribeLookHouseService.hotspot();
        return Result.ok(hotspot);
    }

}
